from sqlalchemy import create_engine, Column, String, DateTime, Integer, Float, func, JSON
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker


# 初始化数据库连接:
engine = create_engine('mysql+pymysql://bi:bi123456@172.16.8.83:3306/publicdb?charset=utf8')

# 创建DBSession类型:
DBSession = sessionmaker(bind=engine)

Base = declarative_base()


class Acticalstaticmodel(Base):
    """
    文章统计数量
    """
    __tablename__ = 'tab_actical_static'

    id = Column(Integer, primary_key=True)
    location = Column(String(10))
    # website 网站　news：报纸　weibo：微博　weixin：微信　webbbs：论坛　webapp：app
    website = Column(Integer)
    news = Column(Integer)
    weixin = Column(Integer)
    webbbs = Column(Integer)
    webapp = Column(Integer)
    weibo = Column(Integer)
    # 正面　负面
    positive = Column(Integer)
    negative = Column(Integer)
    created_at = Column(DateTime, server_default=func.now())



#创建数据表，如果数据表存在则忽视！！！
Base.metadata.create_all(engine)